package com.xiaoxu.intranetweb.mybatisplusSzappdb.vo.Constructor;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.CAshGateVideoBind;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.CIcCardsInfo;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.CProductsInfo;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.entity.CWeightSheets;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.service.ICAshGateVideoBindService;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.service.ICIcCardsInfoService;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.service.ICProductsInfoService;
import com.xiaoxu.intranetweb.mybatisplusSzappdb.vo.GetCWeightSheetsVo;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CWeightSheets2GetCWeightSheetsVo {
    @Autowired
    private ICAshGateVideoBindService iCAshGateVideoBindService;
    @Autowired
    private ICProductsInfoService icProductsInfoService;
    @Autowired
    private ICIcCardsInfoService icIcCardsInfoService;

    public GetCWeightSheetsVo getCWeightSheetsVo(CWeightSheets cWeightSheets) {
        GetCWeightSheetsVo getCWeightSheetsVo = new GetCWeightSheetsVo();
        getCWeightSheetsVo.setId(cWeightSheets.getId());
        getCWeightSheetsVo.setWeishtSheetno(cWeightSheets.getWeishtSheetno());
        getCWeightSheetsVo.setWeishtIccardno(cWeightSheets.getWeishtIccardno());
        QueryWrapper<CIcCardsInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("CARDINF_CARDNO", cWeightSheets.getWeishtIccardno());
        queryWrapper.eq("CARDINF_DELETED", 0);
        CIcCardsInfo cIcCardsInfo = icIcCardsInfoService.getOne(queryWrapper);
        if (cIcCardsInfo != null) {
            getCWeightSheetsVo.setWeiShtIccardAlias(cIcCardsInfo.getCardinfAlias());
        }
        getCWeightSheetsVo.setWeishtTruckno(cWeightSheets.getWeishtTruckno());
        getCWeightSheetsVo.setWeishtTrailerno(cWeightSheets.getWeishtTrailerno());
        getCWeightSheetsVo.setWeishtBoat(cWeightSheets.getWeishtBoat());
        getCWeightSheetsVo.setWeishtShip(cWeightSheets.getWeishtShip());
        String weishtProduct = cWeightSheets.getWeishtProduct();
        getCWeightSheetsVo.setWeishtProduct(weishtProduct);
        getCWeightSheetsVo.setWeishtGrossWght(cWeightSheets.getWeishtGrossWght());
        getCWeightSheetsVo.setWeishtTare(cWeightSheets.getWeishtTare());
        getCWeightSheetsVo.setWeishtNetWght(cWeightSheets.getWeishtNetWght());
        getCWeightSheetsVo.setWeishtOriprice(cWeightSheets.getWeishtOriprice());
        getCWeightSheetsVo.setWeishtOrimoney(cWeightSheets.getWeishtOrimoney());
        getCWeightSheetsVo.setWeishtPrice(cWeightSheets.getWeishtPrice());
        getCWeightSheetsVo.setWeishtMoney(cWeightSheets.getWeishtMoney());
//市场价
        getCWeightSheetsVo.setWeishtMarketPrice(cWeightSheets.getWeishtMarketPrice());

//定价
        getCWeightSheetsVo.setWeightSpecialPrice(cWeightSheets.getWeightSpecialPrice());
// 定价id
        getCWeightSheetsVo.setWeishtPriceId(cWeightSheets.getWeishtPriceId());
//定价类型
        getCWeightSheetsVo.setWeishtPriceType(cWeightSheets.getWeishtPriceType());
//        是否扣款
        getCWeightSheetsVo.setWeishtDeduction(cWeightSheets.getWeishtDeduction());
//        getCWeightSheetsVo.setWeishtBillgross(cWeightSheets.getWeishtBillgross());
//        getCWeightSheetsVo.setWeishtBilltare(cWeightSheets.getWeishtBilltare());
//        getCWeightSheetsVo.setWeishtBillnet(cWeightSheets.getWeishtBillnet());
//        getCWeightSheetsVo.setWeishtDedGangue(cWeightSheets.getWeishtDedGangue());
//        getCWeightSheetsVo.setWeishtDedWater(cWeightSheets.getWeishtDedWater());
//        getCWeightSheetsVo.setWeishtAcceptNet(cWeightSheets.getWeishtAcceptNet());
//        getCWeightSheetsVo.setWeishtProfit(cWeightSheets.getWeishtProfit());
//        getCWeightSheetsVo.setWeishtDepStation(cWeightSheets.getWeishtDepStation());
//        getCWeightSheetsVo.setWeishtMineral(cWeightSheets.getWeishtMineral());
//        getCWeightSheetsVo.setWeishtBatch(cWeightSheets.getWeishtBatch());
//        getCWeightSheetsVo.setWeishtBatchTrucks(cWeightSheets.getWeishtBatchTrucks());
//        weishtCoSupply
        getCWeightSheetsVo.setWeishtCoSupply(cWeightSheets.getWeishtCoSupply());
//        weishtCoSupplyChi
        getCWeightSheetsVo.setWeishtCoSupplyChi(cWeightSheets.getWeishtCoSupplyChi());
//        weishtCo
        getCWeightSheetsVo.setWeishtCo(cWeightSheets.getWeishtCo());
//   weishtChiCo
        getCWeightSheetsVo.setWeishtChiCo(cWeightSheets.getWeishtChiCo());
//        weishtCoTran
        getCWeightSheetsVo.setWeishtCoTran(cWeightSheets.getWeishtCoTran());
//        weishtChiCoTran
        getCWeightSheetsVo.setWeishtChiCoTran(cWeightSheets.getWeishtChiCoTran());
//        weishtPondMoney
        getCWeightSheetsVo.setWeishtPondMoney(cWeightSheets.getWeishtPondMoney());
//            private BigDecimal weishtBillgross;
//
//    private BigDecimal weishtBilltare;
//
//    private BigDecimal weishtBillnet;
        getCWeightSheetsVo.setWeishtBillgross(cWeightSheets.getWeishtBillgross());
        getCWeightSheetsVo.setWeishtBilltare(cWeightSheets.getWeishtBilltare());
        getCWeightSheetsVo.setWeishtBillnet(cWeightSheets.getWeishtBillnet());
//        weishtShipTm
        getCWeightSheetsVo.setWeishtShipTm(cWeightSheets.getWeishtShipTm());
//        weishtDelyTm
        getCWeightSheetsVo.setWeishtDelyTm(cWeightSheets.getWeishtDelyTm());
//        weishtEmptyTm
        getCWeightSheetsVo.setWeishtEmptyTm(cWeightSheets.getWeishtEmptyTm());
//        weishtFullTm
        getCWeightSheetsVo.setWeishtFullTm(cWeightSheets.getWeishtFullTm());
//        weishtEnterTm
        getCWeightSheetsVo.setWeishtEnterTm(cWeightSheets.getWeishtEnterTm());
//        weishtOutTm
        getCWeightSheetsVo.setWeishtOutTm(cWeightSheets.getWeishtOutTm());
//        weishtTranMode
        getCWeightSheetsVo.setWeishtTranMode(cWeightSheets.getWeishtTranMode());
//        weishtOperator
        getCWeightSheetsVo.setWeishtOperator(cWeightSheets.getWeishtOperator());
//        weishtIccardtype
        getCWeightSheetsVo.setWeishtIccardtype(cWeightSheets.getWeishtIccardtype());
//        weishtRemark
        getCWeightSheetsVo.setWeishtRemark(cWeightSheets.getWeishtRemark());
//        weishtModifyTime
        getCWeightSheetsVo.setWeishtModifyTime(cWeightSheets.getWeishtModifyTime());
//        weishtModifyReason
        getCWeightSheetsVo.setWeishtModifyReason(cWeightSheets.getWeishtModifyReason());
////        weishtTruckSn
//        getCWeightSheetsVo.setWeishtTruckSn(cWeightSheets.getWeishtTruckSn());
////        weishtYearSn
        getCWeightSheetsVo.setWeishtYearSn(cWeightSheets.getWeishtYearSn());
////        weishtPredeWght
//        getCWeightSheetsVo.setWeishtPredeWght(cWeightSheets.getWeishtPredeWght());
////        weishtLoadTm
//        getCWeightSheetsVo.setWeishtLoadTm(cWeightSheets.getWeishtLoadTm());
////        weishtLoadEndTm
//        getCWeightSheetsVo.setWeishtLoadEndTm(cWeightSheets.getWeishtLoadEndTm());
////        weishtLoadCostTm
//        getCWeightSheetsVo.setWeishtLoadCostTm(cWeightSheets.getWeishtLoadCostTm());
//        weishtAshgateId
        getCWeightSheetsVo.setWeishtAshgateId(cWeightSheets.getWeishtAshgateId());
//            private String weishtIdentity;
//
//    private String weishtTell;
        getCWeightSheetsVo.setWeishtIdentity(cWeightSheets.getWeishtIdentity());
        getCWeightSheetsVo.setWeishtTell(cWeightSheets.getWeishtTell());
        getCWeightSheetsVo.setWeishtLoadTm(cWeightSheets.getWeishtLoadTm());
        getCWeightSheetsVo.setWeishtLoadEndTm(cWeightSheets.getWeishtLoadEndTm());
//        weishtAshgateName
//        cWeightSheets.getWeishtAshgateId()不等于-1时，查询CAshGateVideoBind表，获取ashgateName，运算符 '!=' 不能应用于 'java.math.BigDecimal'、'int'
        if (cWeightSheets.getWeishtAshgateId().intValue() != -1) {
            QueryWrapper<CAshGateVideoBind> cAshGateVideoBindQueryWrapper = new QueryWrapper<>();
            cAshGateVideoBindQueryWrapper.eq("ASHGATE_ID", cWeightSheets.getWeishtAshgateId());
            cAshGateVideoBindQueryWrapper.eq("ASHGATE_DELETED", 0);
            CAshGateVideoBind cAshGateVideoBind = iCAshGateVideoBindService.getOne(cAshGateVideoBindQueryWrapper);
            if (cAshGateVideoBind != null) {
                getCWeightSheetsVo.setWeishtAshgateName(cAshGateVideoBind.getAshgateName());
            } else {
                getCWeightSheetsVo.setWeishtAshgateName("");
            }
        } else {
            getCWeightSheetsVo.setWeishtAshgateName("");
        }
        if (cWeightSheets.getWeishtSelAshgateId() !=null) {
            getCWeightSheetsVo.setWeishtSelAshgateId(cWeightSheets.getWeishtSelAshgateId());
            QueryWrapper<CAshGateVideoBind> cAshGateVideoBindQueryWrapper = new QueryWrapper<>();
            cAshGateVideoBindQueryWrapper.eq("ASHGATE_ID", cWeightSheets.getWeishtSelAshgateId());
            cAshGateVideoBindQueryWrapper.eq("ASHGATE_DELETED", 0);
            CAshGateVideoBind cAshGateVideoBind = iCAshGateVideoBindService.getOne(cAshGateVideoBindQueryWrapper);
            if (cAshGateVideoBind != null) {
                getCWeightSheetsVo.setWeishtSelAshgateName(cAshGateVideoBind.getAshgateName());
            } else {
                getCWeightSheetsVo.setWeishtSelAshgateName("");
            }
        }
////weishtPrintTimes
//        getCWeightSheetsVo.setWeishtPrintTimes(cWeightSheets.getWeishtPrintTimes());
////weishtSchedule
//        getCWeightSheetsVo.setWeishtSchedule(cWeightSheets.getWeishtSchedule());
////        weishtInLoadno
//        getCWeightSheetsVo.setWeishtInLoadno(cWeightSheets.getWeishtInLoadno());
////        weishtOutLoadno
//        getCWeightSheetsVo.setWeishtOutLoadno(cWeightSheets.getWeishtOutLoadno());
////        weishtSampling
//        getCWeightSheetsVo.setWeishtSampling(cWeightSheets.getWeishtSampling());
////        weishtGrossWghtMode
//        getCWeightSheetsVo.setWeishtGrossWghtMode(cWeightSheets.getWeishtGrossWghtMode());
////        weishtTareWghtMode
//        getCWeightSheetsVo.setWeishtTareWghtMode(cWeightSheets.getWeishtTareWghtMode());
////        weishtBacked
//        getCWeightSheetsVo.setWeishtBacked(cWeightSheets.getWeishtBacked());
////        weishtOut
//        getCWeightSheetsVo.setWeishtOut(cWeightSheets.getWeishtOut());
////        weishtTempout
//        getCWeightSheetsVo.setWeishtTempout(cWeightSheets.getWeishtTempout());
////        weishtTempdeleted
//        getCWeightSheetsVo.setWeishtTempdeleted(cWeightSheets.getWeishtTempdeleted());
//        weishtDeleted
        getCWeightSheetsVo.setWeishtDeleted(cWeightSheets.getWeishtDeleted());

//        dataFrom
        getCWeightSheetsVo.setDataFrom(cWeightSheets.getDataFrom());
        QueryWrapper<CProductsInfo> cProductsInfoQueryWrapper = new QueryWrapper<>();
        cProductsInfoQueryWrapper.eq("PDTINF_PDT", weishtProduct);
        cProductsInfoQueryWrapper.eq("PDTINF_DELETED",0);
        CProductsInfo one = icProductsInfoService.getOne(cProductsInfoQueryWrapper);
        if (one!=null) {
            getCWeightSheetsVo.setProductId(one.getId());
        }
        return getCWeightSheetsVo;
    }
}
